<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP 'Order.jsp' starting page</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link rel="stylesheet" type="text/css"
			href="<%=basePath%>/css/biaoge.css" />
		<link rel="stylesheet" type="text/css"
			href="fancybox/jquery.fancybox-1.3.4.css" />
		<script type="text/javascript"
			src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
		<script type="text/javascript" src="jquery/js/jquery-1.8.2.js"></script>
		<script type="text/javascript"
			src="fancybox/jquery.easing-1.3.pack.js"></script>
		<script type="text/javascript" src="fancybox/jquery.fancybox-1.3.4.js"></script>
		<script type="text/javascript"
			src="fancybox/jquery.fancybox-1.3.4.pack.js"></script>
		<script type="text/javascript"
			src="fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
		<script type="text/javascript"
			src="<%=basePath%>/My97DatePicker/WdatePicker.js"></script>

	</head>
	<script type="text/javascript">
	function getone(a) {
		window.location = "orderdetail.action?orderid=" + a;
	}

	function sele() {
		var da = $("#riqi").val();
		var indusname = $("#gongchang").val();
		//alert("selectBydate.action?datetime='"+da+"'&&indusid="+indusid);
		window.location = "selectBydate.action?datetime=" + da + "&&indusname="
				+ indusname;
	}

	function doHandleMonth(month) {
		if (month.toString().length == 1) {
			month = "0" + month;
		}
		return month;
	}

	function getToDay() {
		var newdate = null;
		var now = new Date();
		var nowYear = now.getFullYear();
		var nowMonth = now.getMonth();
		var nowDate = now.getDate();
		newdate = new Date(nowYear, nowMonth, nowDate);
		nowMonth = doHandleMonth(nowMonth + 1);
		nowDate = doHandleMonth(nowDate);
		//alert(nowYear+"-"+nowMonth+"-"+nowDate);
		return nowYear + "-" + nowMonth + "-" + nowDate;
	}

	$(document).ready(function() {
		setInterval(ajaxfanstate, 5000);
	});

	function ajaxfanstate() {
		//alert("hahah");
		$
				.post("selectorderbydate.action", {
					datetime : getToDay(),
					indusname : ""
				}, function(data) {
					//alert("asdfasdfasd");
						var len = data.jsonob.length;
						//$("#"+id+"").html("已发货");
						//var k='__tag_87$18_已发货__tag_87$40_';
						for ( var i = 0; i < len; i++) {
							//var $("#")
							if (data.jsonob[i].costFeedback != null
									&& data.jsonob[i].costFeedback != "")
								document.getElementById(data.jsonob[i].orderId).innerHTML = "工厂有反馈";
						}
					}, "json");
		//alert("aaaaa");
	}

	function fangda(tupian) {
		$("#" + tupian + "k").fancybox();
	}
	$().ready(function() {
	var options = "<option value=''>-----请  选  择-----</option>";
       $.post(
       "getAllIndustry",
       function(data){
         $.each(data.gonglist,function(index,value){
        options = options+"<option value="+value.industryName+">"+value.industryName+"</option>";
        
         });
         $("select").html(options);
       },"json"
       );
       
	});
</script>
	<body>

		<!--  <div style="margin-left: 200px;"> -->
		<div align="center">
			<!--   <div style="float:right;margin-top:70px">订单查询：<br>选择时间：<input type="text" name="riqi" id="riqi" onclick="JTC.setday({format:'yyyy-MM-dd', readOnly: true})"><br>
      工厂名称：<input type="text" name="gongchang" id="gongchang"><input type="button"  value="查询" onclick="sele()">
        </div> -->
			<div>
				<table>
					<tr>
						<td colspan="2" align="center">
							订单查询：
						</td>
					</tr>
					<tr>
						<td>
							选择时间：
						</td>
						<td>
							<input type="text" name="riqi" id="riqi" class="Wdate"
								onfocus="WdatePicker()">
						</td>
					</tr>
					<tr>
						<td>
							工厂名称：
						</td>
						<td>
							
							<select id="gongchang">
							
							</select>
						</td>
					</tr>
					<tr>
						<td colspan="2" align="center">
							<input type="button" value="查询" onclick=sele();>
						</td>
					</tr>
				</table>
			</div>

			<div style="width: 1000px; margin-left: 70px" id="order">
				<font size="3" color="red">今天的订单：如果没有制作CDR文件，可以点击订单详细信息查看图片制作然后上传图片即可。</font>
				<table id="mytable" cellspacing="6">
					<tr>
						<td>
							订单图片
						</td>
						<td>
							订单名字
						</td>
						<td>
							下单用户
						</td>
						<td>
							下单时间
						</td>
						<td>
							订单详细信息
						</td>
						<td>
							订单对应工厂
						</td>
						<td>
							订单状态
						</td>
						<td>
							是否制作CDR文件
						</td>
					</tr>
					<c:forEach items="${orderlist}" var="order">
						<c:if test="${!empty order.orderName}">
							<tr>
								<td>
									<img src="${order.orderPic}" style="height: 76px; width: 100px" />
									<a id="${order.orderId}k" href="${order.orderPic}"><img
											src="img/fangda.gif" onclick="fangda('${order.orderId}')"
											style="float: right;">
									</a>
								</td>
								<td>
									${order.orderName}
								</td>
								<td>
									${order.userName}
								</td>
								<td>
									<fmt:formatDate value="${order.orderTime}"
										pattern="yyyy-MM-dd HH:mm:ss" />
								</td>
								<td>
									<input type="button" value="查看详细信息"
										onclick="getone('${order.orderId}')">
								</td>
								<td>
									${order.industryName}
								</td>
								<c:choose>
									<c:when test="${order.orderState==0}">
										<td id="${order.orderId}">
											<font size="3" color="black">用户未付款</font>
										</td>
									</c:when>

									<c:when test="${order.orderState==1}">
										<td id="${order.orderId}">
											<font size="3" color="red">用户已付款，未发货</font>
											<c:if test="${! empty order.costFeedback}">
												<font size="3" color="red">工厂有反馈</font>
											</c:if>
										</td>
									</c:when>

									<c:when test="${order.orderState==2}">
										<td id="${order.orderId}">
											<font size="3" color="blue">已发货</font>
											<c:if test="${! empty order.costFeedback}">
												<font size="3" color="blue">工厂有反馈</font>
											</c:if>
										</td>
									</c:when>

									<c:when test="${order.orderState==3}">
										<td id="${order.orderId}">
											<font size="3" color="grey">成功交易</font>
										</td>
									</c:when>

								</c:choose>
								<c:if test="${empty order.CDRurl}">
									<td>
										<font size="3" color="red">未制作</font>
									</td>
								</c:if>
								<c:if test="${!empty order.CDRurl}">
									<td>
										已制作
									</td>
								</c:if>
								<tr>
						</c:if>
					</c:forEach>

				</table>
				<br>

			</div>
		</div>

	</body>
</html>
